package com.feifan.monthhelper.db.dao;

import android.arch.persistence.room.*;

import com.feifan.monthhelper.bean.db.MenstrualRecordBean;

import java.util.List;

@Dao
public interface MenstrualRecordDao {

    @Query("Select * from menstrual_record")
    List<MenstrualRecordBean> getAll();

    @Query("Select * from menstrual_record Where start_date <= (:date) And end_date >= (:date)")
    MenstrualRecordBean loadByDate(long date);

    @Query("Select * from menstrual_record Where start_date = (:start_date) Or end_date = (:end_date)")
    MenstrualRecordBean loadNearByDate(long start_date, long end_date);

    @Query("Select * from menstrual_record Where start_date >= (:start_date) And end_date <= (:end_date)")
    List<MenstrualRecordBean> loadByDate(long start_date, long end_date);

    @Update
    void update(MenstrualRecordBean... users);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(MenstrualRecordBean... users);

    @Insert
    void insertAll(MenstrualRecordBean... users);

    @Delete
    void deleteAll(List<MenstrualRecordBean> users);

    @Delete
    void delete(MenstrualRecordBean... users);
}
